package com.workflow.workflowproject.entity;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;

import java.io.Serial;
import java.util.HashMap;
import java.util.List;

import com.mybatisflex.core.handler.Fastjson2TypeHandler;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.workflow.workflowproject.pojo.ProcessModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

/**
 *  实体类。
 *
 * @author Administrator
 * @since 2024-10-28
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("t_com_flow_form")
public class FlowForm implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 表单id
     */
    @Id(keyType = KeyType.Generator,value= KeyGenerators.snowFlakeId)
    private String id;

    @Column(value = "flow_info_id")
    @Schema(description = "PC端表单")
    private Integer flowInfoId;

    @Column(value = "version_name")
    @Schema(description = "版本名称")
    private String versionName;


    /**
     * 移动端表单
     */
    @Column(value = "mv_form_json",typeHandler = Fastjson2TypeHandler.class)
    @Schema(description = "移动端表单")
    private List<JSONObject> mvFormJson;

    /**
     * PC端表单
     */
    @Column(value = "pc_form_json",typeHandler = Fastjson2TypeHandler.class)
    @Schema(description = "PC端表单")
    private List<JSONObject> pcFormJson;
    /**
     * 流程定义id
     */
    @Column(value = "flow_id")
    @Schema(description = "流程定义id")
    private String flowId;
    /**
     * 流程bpmn
     */
    @Column(value = "flow_bpmn_xml")
    @Schema(description = "流程bpmn")
    private String flowBpmnXml;
    /**
     * 流程bpmn
     */
    @Column(value = "low_flow_json")
    @Schema(description = "lowflow的json")
    private String lowFlowJson;


    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(value = "create_time",onInsertValue = "now()")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(value = "update_time",onUpdateValue = "now()")
    @Schema(description = "修改时间")
    private LocalDateTime updateTime;

    @Column(value = "exist",isLogicDelete = true)
    @Schema(description = "是否删除")
    private Integer exist;

    @Column(value = "state")
    @Schema(description = "是否上线（0、未上线；1、已上线）")
    private Integer state;

    @Column(ignore = true)
    @Schema(description = "流程model")
    private ProcessModel processModel;
}
